<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      >
    <body>
        <ui:composition template="./template.xhtml">
            <ui:define name="title">
                Winner Page
            </ui:define>
            <ui:define name="content">
                <h2 class="art-postheader">Winner
                </h2>
                <f:view>
                    <h:form id="frNotLogin">
                        <c:if test="${user == null}">
                        <p:dataTable value="#{winnerController.items}" var="item"
                                     paginator="true" rows="10"
                                     paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                     style="font-size: 12px;">
                        <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Winner ID"/>
                                </f:facet>
                                <h:outputText value="#{item.winnerID}" />
                        </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Winner Name"/>
                                </f:facet>
                                <h:outputText value="#{item.registration.userInfo.userName}" />
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Event Name"/>
                                </f:facet>
                                <h:outputText value="#{item.registration.eventInfo.eventName}" />
                            </p:column>
                                 <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Prize"/>
                                </f:facet>
                                <h:outputText value="#{item.price}" />
                            </p:column>
                            <p:column>
                                <f:facet name="header">
                                    <h:outputText value="Action"/>
                                </f:facet>
                                <p:commandButton image="ui-icon ui-icon-search" action="#{winnerController.prepareView}" title="View Details" ajax="false"/>
                            </p:column>
                        </p:dataTable>
                    </c:if>
                    </h:form>
                    <h:form id="frLogin" >
                        <c:if test="${user != null}">
                            <c:set value="#{userController.current.isAdmin}" var="role"/>
                             <c:if test="${role == true}">
                                <p:commandButton icon="ui-icon-plusthick" action="#{winnerController.prepareCreate}" value="Create New Winner" ajax="false"/>
                            </c:if>
                            <br/>
                            <p:dataTable value="#{winnerController.items}" var="item"
                                         paginator="true" rows="10"
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                                         rowsPerPageTemplate="5,10,15"
                                         style="font-size: 12px;"
                                         >
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Winner ID"/>
                                    </f:facet>
                                    <h:outputText value="#{item.winnerID}"/>
                                </p:column>
                           
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Winner Name"/>
                                    </f:facet>
                                    <h:outputText value="#{item.registration.userInfo.userName}">
                                    </h:outputText>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Event Name"/>
                                    </f:facet>
                                    <h:outputText value="#{item.registration.eventInfo.eventName}" />
                                </p:column>
                               <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Prize"/>
                                    </f:facet>
                                    <h:outputText value="#{item.price}"/>
                                </p:column>
                                <c:if test="${role == true}">
                                    <p:column sortBy="#{item.isDelete}" >
                                        <f:facet name="header">
                                            <h:outputText value="Delete - Restore"/>
                                        </f:facet>
                                        <p:selectBooleanCheckbox value="#{item.isDelete}" disabled="true" />
                                    </p:column>
                                    <p:column>
                                        <f:facet name="header">
                                            <h:outputText value="Action"/>
                                        </f:facet>
                                        <p:commandButton image="ui-icon ui-icon-search" action="#{winnerController.prepareView}" title="View Details" ajax="false"/>
                                        <p:commandButton image="ui-icon ui-icon-pencil" action="#{winnerController.prepareEdit}" title="Edit" ajax="false"/>
                                        <p:commandButton image="ui-icon ui-icon-close"
                                                         title="De-Activate"
                                                         rendered="#{!item.isDelete}"
                                                         action="#{winnerController.delete}"
                                                         />                                        
                                        <p:commandButton image="ui-icon-check" action="#{winnerController.restore}" title="Re-Activate" ajax="false" rendered="#{item.isDelete}"/>
                                    </p:column>
                                </c:if>
                            </p:dataTable>
                        </c:if>
                    </h:form>
                </f:view>

            </ui:define>

        </ui:composition>

    </body>
</html>
